<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html;charset=utf-8" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>用户列表</title>
  <link rel="icon" href="${base}/favicon.ico" type="image/ico">
  <link href="${base}/css/bootstrap.min.css" rel="stylesheet">
  <link href="${base}/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="${base}/css/style.min.css" rel="stylesheet">
  <style>
    .myHead{
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  </style>
</head>

<body>
<div class="container-fluid">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-toolbar clearfix">
          <form class="pull-right search-bar" method="get" action="${base}/user/show" role="form">
            <input type="hidden" name="type" value="2">
            <div class="input-group">
              <div class="input-group-btn">
                <input type="hidden" name="search_field" id="search-field" value="title">
                <button class="btn btn-default dropdown-toggle" id="search-btn" type="submit">搜索</button>
              </div>
              <input type="text" class="form-control" value="" name="keyword" placeholder="   请输入搜索内容">
            </div>
          </form>
          <div class="toolbar-btn-action">
            <a class="btn btn-primary m-r-5" href="${base}/user/toAdd?newType=2"><i class="mdi mdi-plus"></i> 新增</a>
            <a class="btn btn-success m-r-5" onclick="openAll()"><i class="mdi mdi-check"></i> 启用</a>
            <a class="btn btn-warning m-r-5" onclick="closeAll()"><i class="mdi mdi-block-helper"></i> 禁用</a>
            <a class="btn btn-danger" onclick="delAll()"><i class="mdi mdi-window-close"></i> 删除</a>
          </div>
        </div>
        <div class="card-body">
          <form action="" method="post" id="fm">
            <div class="table-responsive">
              <table class="table table-bordered">
                <thead>
                <tr>
                  <th>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" id="check-all"><span></span>
                    </label>
                  </th>
                  <th>用户编号</th>
                  <th>账号</th>
                  <th>姓名</th>
                  <th>头像</th>
                  <th>手机</th>
                  <th>班级</th>
                  <th>性别</th>
                  <th>状态</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="u" items="${p.list}">
                  <c:if test="${u.r.id eq 2}">
                    <tr>
                      <td>
                        <label class="lyear-checkbox checkbox-primary">
                          <input type="checkbox" name="id" value="${u.id}"><span></span>
                        </label>
                      </td>
                      <td>${u.id}</td>
                      <td>${u.account}</td>
                      <td>${u.name}</td>
                      <td><img class="myHead" src="${base}/upload/${u.headpic}" alt="图片丢了"></td>
                      <td>${u.phone}</td>
                      <td>${u.c eq null?"无":u.c.name}</td>
                      <td>${u.sex == 1?"男":"女"}</td>
                      <td>
                        <c:if test="${u.status eq 1}"><font class="text-success">正常</font></c:if>
                        <c:if test="${u.status eq 0}"><font class="text-danger">注销</font></c:if>
                      </td>
                      <td>
                        <div class="btn-group">
                          <a class="btn btn-xs btn-default" href="${base}/user/toUpdate?id=${u.id}&roleid=${u.roleid}" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                          <a class="btn btn-xs btn-default" href="${base}/user/del?id=${u.id}&headpic=${u.headpic}&roleid=${u.roleid}" onclick="return confirm('是否删除')" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                        </div>
                      </td>
                    </tr>
                  </c:if>
                </c:forEach>
                </tbody>
              </table>
            </div>
          </form>
          <ul class="pagination">
            <li><a href="${base}/user/show?pageNum=1&type=2&keyword=${keyword}">«</a></li>
            <li><a href="${base}/user/show?pageNum=${p.prePage}&type=2&keyword=${keyword}">上一页</a></li>
            <c:forEach var="i" items="${p.navigatepageNums}">
              <li <c:if test="${i eq p.pageNum}">class="active"</c:if> ><a href="${base}/user/show?pageNum=${i}&type=2&keyword=${keyword}">${i}</a></li>
            </c:forEach>
            <li><a href="${base}/user/show?pageNum=${p.nextPage}&type=2&keyword=${keyword}">下一页</a></li>
            <li><a href="${base}/user/show?pageNum=${p.pages}&type=2&keyword=${keyword}">»</a></li>
          </ul>
        </div>
      </div>
    </div>

  </div>

</div>

<script type="text/javascript" src="${base}/js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${base}/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${base}/js/main.min.js"></script>
<script type="text/javascript">
    $(function(){
        $('.search-bar .dropdown-menu a').click(function() {
            var field = $(this).data('field') || '';
            $('#search-field').val(field);
            $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
        });
    });

</script>
<script>
    if (${!empty error}) {
        lightyear.loading('show');
        // 假设ajax提交操作
        setTimeout(function () {
            lightyear.loading('hide');
            lightyear.notify('${error}', 'danger', 0);
        }, 0)
    } else {
        if (${!empty success}) {
            lightyear.loading('show');
            // 假设ajax提交操作
            setTimeout(function () {
                lightyear.loading('hide');
                lightyear.notify('${success}', 'success', 0);
            }, 0)
        }
    }
</script>
<script>
    function openAll() {
        $("#fm").attr("action", "${base}/user/change?tag=open&type=2");
        $("#fm").submit();
    }
    function closeAll() {
        $("#fm").attr("action", "${base}/user/change?tag=close&type=2");
        $("#fm").submit();
    }
    function delAll() {
        $("#fm").attr("action", "${base}/user/delAll?type=2");
        $("#fm").submit();
    }
</script>
</body>
</html>